package com.gugee.ins.data.common.msg;

import com.gugee.ins.data.common.util.ProtostuffUtil;
import lombok.Data;
import lombok.ToString;
import org.apache.kafka.common.serialization.Deserializer;
import org.apache.kafka.common.serialization.Serializer;

/**
 * insBrand消息
 * @author Huangxin
 */
@ToString(callSuper = true)
@Data
public class InsProductMessage extends InsMessage{
    /**
     * 商品id
     */
    private Long pid;

    /**
     * 商品名称
     */
    private String productName;

    /**
     * 描述
     */
    private String description;

    /**
     * 外链接
     */
    private String externalUrl;

    /**
     * msg类型
     */
    private int typeCode = 0;

    /**
     * 任务消息的反序列号
     *
     * @author luolifeng
     * @version 1.0.0
     * Date 2020/10/04
     * Time 15:03
     */
    public static class MsgDeserializer implements Deserializer<InsProductMessage> {
        @Override
        public InsProductMessage deserialize(String topic, byte[] bytes) {
            return ProtostuffUtil.deserializer(bytes, InsProductMessage.class);
        }
    }

    /**
     * Description 类描述
     *
     * @author luolifeng
     * @version 1.0.0
     * Date 2020/10/04
     * Time 15:12
     */
    public static class MsgSerializer implements Serializer<InsProductMessage> {
        @Override
        public byte[] serialize(String topic, InsProductMessage bloggerMessage) {
            return ProtostuffUtil.serializer(bloggerMessage, InsProductMessage.class);
        }
    }
}
